from rest_framework import serializers

from goods.models import SKUImage, SKU


class SKUImagesSerializer(serializers.ModelSerializer):

    # 重写
    sku = serializers.StringRelatedField(read_only=True)
    sku_id = serializers.IntegerField()

    class Meta:
        model = SKUImage
        fields = "__all__"

# 获取所有的sku的信息，展示在页面中
class SKUSimpleSerializer(serializers.ModelSerializer):
    class Meta:
        model = SKU
        fields = ("id","name")